#pragma once

#include<pthread.h>
#include"mutex.hpp"
namespace CondModul
{
    class Cond
    {
    public:
        Cond()
        {
            pthread_cond_init(&_cond,nullptr);
        }
        int Wait(MutexModel::Mutex& mutex)
        {
            return pthread_cond_wait(&_cond,mutex.GetMutexPtr());
        }
        int Notify()
        {
            return pthread_cond_signal(&_cond);
        }
        int NotifyAll()
        {
            return pthread_cond_broadcast(&_cond);
        }
        ~Cond()
        {
            pthread_cond_destroy(&_cond);
        }
    private:
        pthread_cond_t _cond;
    };
}